function dep_maxima, image, wsize ;must be odd
	imout = image
	imout[*] = 0 ;binary image
	win = intarr(wsize,wsize)
	win[*] = 1
	wind = indgen(wsize,wsize, 2)
	wind[*,*,0] = rebin(indgen(wsize) - wsize/2,wsize,wsize)
	wind[*,*,1] = transpose(wind[*,*,0])

	imdim = size(image, /dimensions)
	numpixels = (imdim[0] - wsize) * (imdim[1] - wsize)
	index = intarr(wsize, wsize, numpixels, 2)

	pointlist = intarr(numpixels, 2)
	pointlist[*,0] = rebin((indgen(imdim[0] - wsize)), (imdim[0] - wsize) * (imdim[1] - wsize))
	pointlist[*,1] = rebin((indgen(imdim[1] - wsize)), (imdim[1] - wsize), (imdim[0] - wsize))
	pointlist[*]+=wsize/2

	for i=0l, numpixels - 1 do begin
		index[*,*,i,0] = wind[*,*,0]
		index[*,*,i,1] = wind[*,*,1]
	endfor

	for i=0L, numpixels - 1 do index[*,*,i,0] += pointlist[i,0]
	for i=0L, numpixels - 1 do index[*,*,i,1] += pointlist[i,1]

	for i=0L, numpixels - 1 do begin
		a = max(image[reform(index[*,*,i,0]), reform(index[*,*,i,1])])
		if (image[index[wsize/2, wsize/2, i, 0], index[wsize/2, wsize/2, i, 1]] eq a) then begin
			imout[index[wsize/2, wsize/2, i, 0], index[wsize/2, wsize/2, i,1]] = 1
		endif

	endfor
	return, imout
end

;invert the input image, then do a maxima
function dep_minima, image, wsize
	mid = max(image) - min(image)
	invimage = (mid - image) + mid
	return, maxima(invimage, wsize)

end